<template>
  <!--
    	作者：luoyiming
    	时间：2019-10-26
    	描述：车辆-详情
    -->
  <div class="product-add">
    <!--form表单-->
    <el-form size="small" ref="form" :model="form" label-width="200px">
      <!--详情-->

      <el-form-item label="账号类别">
        <el-select v-model="form.info.type" placeholder="请选择" :disabled="true">
          <el-option v-for="(item, index) in category" :key="index" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="开户行" prop="bank_name">
        <el-input class="max-w460" v-model="form.info.bank_name" :disabled="true"></el-input>

      </el-form-item>
      <el-form-item label="提现账号" prop="info.bank_number">
        <el-input class="max-w460" v-model="form.info.bank_number" :disabled="true"></el-input>

      </el-form-item>

      <el-form-item label="提现金额" prop="info.money">
        <el-input class="max-w460" v-model="form.info.money" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="管理员备注">
        <el-input type="textarea" v-model="form.info.remark" placeholder="管理员备注"></el-input>
      </el-form-item>

      <el-form-item label="状态"  v-if="info.status == 0 ">
        <el-radio-group v-model="form.status">
          <el-radio :label="1">已处理</el-radio>
           <el-radio :label="2">驳回</el-radio>
        </el-radio-group>
      </el-form-item>

      <!--提交-->
      <div class="common-button-wrapper" v-if="info.status == 0 ">
        <el-button size="small" type="info" @click="cancelFunc">取消</el-button>
        <el-button size="small" type="primary" @click="onSubmit" :loading="loading">提交</el-button>
      </div>
    </el-form>

  </div>
</template>

<script>
  import UserApi from '@/api/user.js';
  export default {

    data() {
      return {
        /*form表单数据*/
        form: {
          id: 0,
          info: {
            status: 0
          },
        },
        loading: false,
        info: {},
        category: [
          {name:'微信',id:1},
          {name:'支付宝',id:2},
          {name:'银行卡',id:3},
        ],
      };
    },
    created() {
      this.form.id = this.$route.query.id;
      this.getData();
    },
    methods: {
      /*获取参数*/
      getData() {
        let self = this;
        UserApi.withdrawal_detail({
            id: self.form.id
          }, true)
          .then(res => {
            console.log(res);
            self.form.info = res.data.info;
            self.info = res.data.info;
          })
          .catch(error => {

          });
      },

      /*提交*/

      onSubmit() {
        let self = this;
        let form = self.form;
        self.$refs.form.validate((valid) => {
          if (valid) {
            self.loading = true;
            UserApi.withdrawal_Post(form, true)
              .then(data => {
                self.loading = false;
                if (data.code == 1) {
                  self.$message({
                    message: '恭喜你，修改成功',
                    type: 'success'
                  });
                  self.$router.push('/user/balance/withdrawal');
                } else {
                  self.loading = false;
                }
              })
              .catch(error => {
                self.loading = false;
              });
          }
        });
      },

      /*取消*/
      cancelFunc() {
        this.$router.back(-1);
      },
      /*打开弹出层*/
      userClick() {
        this.open_user = true;
      },

      /*关闭获取用户弹窗*/
      closeDialogFunc(e) {
        if (e.type != 'error') {
          this.user_info = e.params[0];
          this.form.info.user_id = e.params[0].user_id;
        }
        this.open_user = false;
      },

    }

  };
</script>

<style lang="scss" scoped>
  .basic-setting-content {}

  .product-add {
    padding-bottom: 50px;
  }

  .img {
    margin-top: 10px;
  }
</style>
